#include"Mario.h"
using namespace std;

int main() {
    int way[10] = { 0,1,2,-1,4,-1,4,3,-1,-1 };
    unique_ptr<Mario> mario(new Mario());
    string input;
    int Status = 0;
    int flag = 0;
    int sta;  
    while (mario->Flag()) {
        cout << "Input d to move forward; Input a to move back; Input w to dodge" << endl;
        cout << "0 is Mario, 1,2,3 are bonus, 4 is the enemy, -1 is the way" << endl << endl;
        for (int a = 0; a < 10; a++)
            cout << "  " << way[a] << "  ";
        cout << endl;
        for (int b = 0; b < 55; b++)
            cout << "=";
        cout << endl;
        cin >> input;
        if (input == "d") {
            way[Status] = -1;
            Status++;
            sta = Status + 1;
            if (way[Status] == 1)
                mario->GotFeather();
            else if (way[Status] == 2)
                mario->GotFireFlower();
            else if (way[Status] == 3)
                mario->GotMushroom();
            else if (way[Status] == 4) {
                mario->MetMonster();
            }
            if (way[sta] == 4)
                cout << "Waring: There will be a monster in next step" << endl;           
            way[Status] = 0;
        }
        else if (input == "a") {
            if (Status > 0) {
                way[Status--];
                way[Status] = 0;
                int temp = Status + 1;
                way[temp] = -1;
            }
            else
                cout << "Error" << endl;
        }
        else if (input == "w") {
            way[Status] = -1;
            Status += 2;
            if (way[Status] == 4)
                mario->MetMonster();
            way[Status] = 0;
            cout << "Dodge" << endl;
        }
        else {
            cout << "Input Error" << endl;
        }
        flag++;
        system("pause");
        system("cls");
        if (flag == 8) {
            mario->ReportCoin();
            cout << "The End" << endl;
            exit(0);
        }
        if (mario->Flag() == 0)
            cout << "Game Over" << endl;
    }
    return 0;
}